package com.lb.algorithm;

/**
 * @version 1.0
 * @Author: Edward
 * @Date: 2021/10/25 10:11
 * @Description: 查找数
 */
public class FindNumber {
    public static void printOddTimesNum2(int[] arr) {
        int eor = 0;
        for (int cur : arr) {
            eor ^= cur;
        }

        // eor = a ^ b;
        // eor != 0
        // eor必然有一个位置上是1

        // 提取出最右的1
        int rightOne = eor & (~eor + 1);
        // eor'
        int onlyOne = 0;
        for (int cur : arr) {
            if ((cur & rightOne) == 1) {
                onlyOne ^= cur;
            }
        }
        System.out.println(onlyOne + " " + (eor ^ onlyOne));
    }

    public static void main(String[] args) {
        int[] cur = {2,3,1,8,12,2,3,9,10};
        printOddTimesNum2(cur);
    }
}
